from abc import ABC
from dataclasses import dataclass
from typing import List, Set, Any, Optional
from datetime import datetime


class Event(ABC):
    """事件基类"""
    def __init__(self):
        self.timestamp = datetime.now()


@dataclass
class CellEditedEvent(Event):
    """单元格编辑事件"""
    row: int
    col: int
    old_value: str
    new_value: str


@dataclass
class RowAddedEvent(Event):
    """行添加事件"""
    row_index: int
    row_data: List[str]


@dataclass
class RowInsertedEvent(Event):
    """行插入事件"""
    row_index: int
    row_data: List[str]


@dataclass
class RowDeletedEvent(Event):
    """行删除事件"""
    row_index: int
    row_data: List[str]


@dataclass
class ColumnAddedEvent(Event):
    """列添加事件"""
    col_index: int
    header: str


@dataclass
class ColumnInsertedEvent(Event):
    """列插入事件"""
    col_index: int
    header: str
    default_value: str


@dataclass
class ColumnRemovedEvent(Event):
    """列删除事件"""
    col_index: int
    header: str


@dataclass
class ColumnReorderedEvent(Event):
    """列重排序事件"""
    old_order: List[int]
    new_order: List[int]


@dataclass
class ColumnMarkedEvent(Event):
    """列标记事件"""
    old_marked: Set[int]
    new_marked: Set[int]


@dataclass
class RowStatusChangedEvent(Event):
    """行状态变更事件"""
    row_indices: List[int]
    action: str  # 'disable' or 'enable'


@dataclass
class DataLoadedEvent(Event):
    """数据加载事件"""
    file_path: str
    row_count: int
    col_count: int


@dataclass
class DataSavedEvent(Event):
    """数据保存事件"""
    file_path: str
    row_count: int
    col_count: int